package com.example.javanewwork.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.javanewwork.entity.Produce;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeviceMapper extends BaseMapper<Produce> {


    @Select("select deviceStatus from devices where id = #{i}")
    int test(int i);


    @Select("select * from devices")
    List<Produce> findAlldevice();


    @Delete("delete from devices where id=#{id}")
    void deleteByid(int id);

    @Update("update devices set deviceName = #{devicename},deviceType = #{devicetype}," +
            "deviceStatus=#{devicestatus},devicePrice= #{deviceprice} where id=#{id}")
    void modifydevice(int id, String devicename, String devicetype, Integer devicestatus, String deviceprice);

//    @Insert("insert into devices(id,deviceName,deviceType,devicePrice,deviceStatus,buyer,dataAdded) values(#{produce}) ")
//    void insertNewDevice(Produce produce);

    @Insert("insert into devices(deviceName,deviceType,deviceStatus,devicePrice) values(#{devicename},#{devicetype}," +
            "#{devicestatus},#{deviceprice}) ")
    void insertNewDevice(String devicename, String devicetype, Integer devicestatus, String deviceprice);




    List<Produce> selectAll();

    @Select("select * from devices where deviceType = #{type}")
    List<Produce> serachByType(String type);

    @Select("select count(*) from devices where deviceType = #{type} and deviceStatus = #{num}")
    int serachbroken(String type, int num);


}
